<?php
error_reporting("E_ALL^E_NOTICE");
session_start();
include './function/Tampil2.php';
?>
<html>
    <head>
        <meta name="key/words" content="berbagi,charity,community"/>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="css/bootstrap.css">       
        <link rel="stylesheet" href="style.css">   
        <title>Semua Berbagi-Indonesia Charity Community</title>
        <script type="text/javascript">
            $(document).ready(function () {
                $("#submit").click(function () {
                    var katakunci_value = $("#katakunci").val();
                    var kategori_value = $("#kategori").val();
                    var provinsi_value = $("#provinsi").val();
                    $.post("hasilcari.php", {katakunci: katakunci_value, kategori: kategori_value, propinsi: provinsi_value}).done(function (data) {
                        $("#response").html(data);
                    });
                });
            })
        </script>
    </head>
    <body>
        <?php
        if (isset($_SESSION['user'])) {
            $status = $_SESSION['user']['status'];
        }
        $t = new Tampil2();
        ?>
        <div class="container">
            <div class="navbar navbar-default" role="navigation">
                <div class="container-fluid">
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle collapsed togle_margin" data-toggle="collapse" data-target=".navbar-collapse"> 
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span> 
                            <span class="icon-bar"></span> 
                            <span class="icon-bar"></span> 
                        </button> 
                        <form class="navbar-form" role="search">
                            <div class="input-group">
                                <input type="text" class="form-control" placeholder="Search" name="text_search">
                                <div class="input-group-btn">
                                    <button class="btn btn-default buttonCari" type="submit" name="button_search"><i class="glyphicon glyphicon-search"></i></button>
                                </div>
                            </div>
                        </form>
                    </div> 
                    <div class="navbar-collapse collapse"> 
                        <div class="navbar-collapse collapse"> 
                            <?php
                            if (!isset($_SESSION['user'])) {
                                ?>
                                <ul class="nav navbar-nav navbar-right"> 
                                    <li>
                                        <a href="http://semuaberbagi.com/masuk.php">Masuk</a>
                                    </li>
                                    <li>
                                        <a href="http://semuaberbagi.com/daftar.php">Daftar</a>
                                    </li>
                                    <li>
                                        <a href="http://semuaberbagi.com/index.php">Beranda</a>
                                    </li>
                                </ul>
                                <?php
                            } else {
                                ?>
                                <ul class="nav navbar-nav navbar-right"> 
                                    <li>
                                        <a href="clearsession.php">Logout</a>
                                    </li>
                                    <li>
                                        <a href="http://semuaberbagi.com/index.php">Beranda</a>
                                    </li>
                                </ul>                        
                                <div class="navbar-text navbar-right">Masuk sebagai <?php echo $status ?>     |</div>
                                <?php
                            }
                            ?>
                        </div> 
                    </div> 
                </div>
            </div>
            <div class="jumbotron utama">
                <form action="hasilcari.php" method="GET">
                    <div class="row">
                        <div class="col-md-12 col-xs-12 formcari">
                            <input type="text" class="form-control" placeholder="Kata Kunci" name="katakunci"/>
                        </div>
                        <div class="col-md-12 col-xs-12 formcari">
                            <select class="form-control" name="kategori">
                                <option value="">Kategori</option>
                                <?php
                                for ($index2 = 0; $index2 < sizeof($t->tampilIDKategori()); $index2++) {
                                    ?>
                                    <option value="<?php echo $t->tampilIDKategori()[$index2] ?>"><?php echo $t->tampilKategori()[$index2] ?></option>
                                    <?php
                                }
                                ?>
                            </select>
                        </div>
                        <div class="col-md-12 col-xs-12 formcari">
                            <select class="form-control" name="provinsi">
                                <option value="">Provinsi</option>
                                <?php
                                for ($index3 = 0; $index3 < sizeof($t->tampilIdProvinsi()); $index3++) {
                                    ?>
                                    <option value="<?php echo $t->tampilIdProvinsi()[$index3] ?>"><?php echo $t->tampilProvinsi()[$index3] ?></option>
                                    <?php
                                }
                                ?>
                            </select>
                        </div>
                        <div class="col-md-12 col-xs-12" style="width: 10%">
                            <input type="submit" class="btn btn-primary" value="CARI" name="cari"/>
                        </div>
                    </div>
                </form>
            </div>
            <div class="panel panel-default panelKat">                
                <?php
                $count = 0;
                $iftrue = 1;
                $katakunci = $_GET['katakunci'];
                $kategori = $_GET['kategori'];
                $provinsi = $_GET['provinsi'];
                if ($kategori == '' && $provinsi == '') {
                    if (sizeof($t->TampilHasilCariBarang5($katakunci)) > 0) {
                        for ($index = 0; $index < 20 && $iftrue == 1; $index++) {
                            ?><div class="row"><?php
                            for ($index1 = 0; $index1 < 4 && $iftrue == 1; $index1++) {
                                if ($count < sizeof($t->TampilHasilCariBarang5($katakunci))) {
                                    ?>
                                        <div class="col-md-3 col-xs-12">
                                            <center>
                                                <div class="panel-body utama">
                                                    <a href="deskripsiBarang.php?barang=<?php echo $t->TampilHasilCariBarang5($katakunci)[$count] ?>"><img src="<?php echo $t->TampilUrlGambarBarang($t->TampilHasilCariBarang5($katakunci)[$count]) ?>" class="img-thumbnail"/></a>
                                                    <a href="deskripsiBarang.php?barang=<?php echo $t->TampilHasilCariBarang5($katakunci)[$count] ?>"><b><center><?php echo $t->TampilNamaBarang($t->TampilHasilCariBarang5($katakunci)[$count]) ?></center></b></a>
                                                    <?php
                                                    if ($status != '') {
                                                        ?>
                                                        <!--                                                <div class="row">
                                                                                                            <div class="col-md-5 col-xs-3">
                                                                                                                <h5 class="h5Like"><a href="#">Like  <span class="badge">200</span></a></h5>
                                                                                                            </div>
                                                                                                            <div class="col-md-7 col-xs-4">
                                                                                                                <h5 class="h5Comment"><a href="#">Comment  <span class="badge">150</span></a></h5>
                                                                                                            </div>
                                                                                                        </div>-->
<!--                                                        <br>
                                                        <ul class="list-group">
                                                            <li class="list-group-item"></li>
                                                            <li class="list-group-item"></li>
                                                            <li class="list-group-item"></li>
                                                            <li class="list-group-item"></li>
                                                        </ul>-->
                                                    <?php }
                                                    ?>
                                                </div>
                                            </center>
                                        </div>
                                        <?php
                                    } else {
                                        $iftrue = 0;
                                    }
                                    $count++;
                                }
                                ?></div><?php
                        }
                    } else {
                        ?>
                        <h2>No Result</h2>
                        <?php
                    }
                } else if ($katakunci == '' && $provinsi == '') {
                    if (sizeof($t->TampilHasilCariBarang6($kategori)) > 0) {
                        for ($index = 0; $index < 20 && $iftrue == 1; $index++) {
                            ?><div class="row"><?php
                            for ($index1 = 0; $index1 < 4 && $iftrue == 1; $index1++) {
                                if ($count < sizeof($t->TampilHasilCariBarang6($kategori))) {
                                    ?>
                                        <div class="col-md-3 col-xs-12">
                                            <center>
                                                <div class="panel-body utama">
                                                    <a href="deskripsiBarang.php?barang=<?php echo $t->TampilHasilCariBarang6($kategori)[$count] ?>"><img src="<?php echo $t->TampilUrlGambarBarang($t->TampilHasilCariBarang6($kategori)[$count]) ?>" class="img-thumbnail"/></a>
                                                    <a href="deskripsiBarang.php?barang=<?php echo $t->TampilHasilCariBarang6($kategori)[$count] ?>"><b><center><?php echo $t->TampilNamaBarang($t->TampilHasilCariBarang6($kategori)[$count]) ?></center></b></a>
                                                    <?php
                                                    if ($status != '') {
                                                        ?>
                                                        <!--                                                <div class="row">
                                                                                                            <div class="col-md-5 col-xs-3">
                                                                                                                <h5 class="h5Like"><a href="#">Like  <span class="badge">200</span></a></h5>
                                                                                                            </div>
                                                                                                            <div class="col-md-7 col-xs-4">
                                                                                                                <h5 class="h5Comment"><a href="#">Comment  <span class="badge">150</span></a></h5>
                                                                                                            </div>
                                                                                                        </div>-->
                                                        <br>
                                                        <ul class="list-group">
                                                            <li class="list-group-item"></li>
                                                            <li class="list-group-item"></li>
                                                            <li class="list-group-item"></li>
                                                            <li class="list-group-item"></li>
                                                        </ul>
                                                    <?php }
                                                    ?>
                                                </div>
                                            </center>
                                        </div>
                                        <?php
                                    } else {
                                        $iftrue = 0;
                                    }
                                    $count++;
                                }
                                ?></div><?php
                        }
                    } else {
                        ?>
                        <h2>No Result</h2>
                        <?php
                    }
                } else if ($katakunci == '' && $kategori == '') {
                    if (sizeof($t->TampilHasilCariBarang7($provinsi)) > 0) {
                        for ($index = 0; $index < 20 && $iftrue == 1; $index++) {
                            ?><div class="row"><?php
                            for ($index1 = 0; $index1 < 4 && $iftrue == 1; $index1++) {
                                if ($count < sizeof($t->TampilHasilCariBarang7($provinsi))) {
                                    ?>
                                        <div class="col-md-3 col-xs-12">
                                            <center>
                                                <div class="panel-body utama">
                                                    <a href="deskripsiBarang.php?barang=<?php echo $t->TampilHasilCariBarang7($provinsi)[$count] ?>"><img src="<?php echo $t->TampilUrlGambarBarang($t->TampilHasilCariBarang7($provinsi)[$count]) ?>" class="img-thumbnail"/></a>
                                                    <a href="deskripsiBarang.php?barang=<?php echo $t->TampilHasilCariBarang7($provinsi)[$count] ?>"><b><center><?php echo $t->TampilNamaBarang($t->TampilHasilCariBarang7($provinsi)[$count]) ?></center></b></a>
                                                    <?php
                                                    if ($status != '') {
                                                        ?>
                                                        <!--                                                <div class="row">
                                                                                                            <div class="col-md-5 col-xs-3">
                                                                                                                <h5 class="h5Like"><a href="#">Like  <span class="badge">200</span></a></h5>
                                                                                                            </div>
                                                                                                            <div class="col-md-7 col-xs-4">
                                                                                                                <h5 class="h5Comment"><a href="#">Comment  <span class="badge">150</span></a></h5>
                                                                                                            </div>
                                                                                                        </div>-->
                                                        <br>
                                                        <ul class="list-group">
                                                            <li class="list-group-item"></li>
                                                            <li class="list-group-item"></li>
                                                            <li class="list-group-item"></li>
                                                            <li class="list-group-item"></li>
                                                        </ul>
                                                    <?php }
                                                    ?>
                                                </div>
                                            </center>
                                        </div>
                                        <?php
                                    } else {
                                        $iftrue = 0;
                                    }
                                    $count++;
                                }
                                ?></div><?php
                        }
                    } else {
                        ?>
                        <h2>No Result</h2>
                        <?php
                    }
                } else if ($katakunci == '') {
                    if (sizeof($t->TampilHasilCariBarang4($kategori, $provinsi)) > 0) {
                        for ($index = 0; $index < 20 && $iftrue == 1; $index++) {
                            ?><div class="row"><?php
                            for ($index1 = 0; $index1 < 4 && $iftrue == 1; $index1++) {
                                if ($count < sizeof($t->TampilHasilCariBarang4($kategori, $provinsi))) {
                                    ?>
                                        <div class="col-md-3 col-xs-12">
                                            <center>
                                                <div class="panel-body utama">
                                                    <a href="deskripsiBarang.php?barang=<?php echo $t->TampilHasilCariBarang4($kategori, $provinsi)[$count] ?>"><img src="<?php echo $t->TampilUrlGambarBarang($t->TampilHasilCariBarang4($kategori, $provinsi)[$count]) ?>" class="img-thumbnail"/></a>
                                                    <a href="deskripsiBarang.php?barang=<?php echo $t->TampilHasilCariBarang4($kategori, $provinsi)[$count] ?>"><b><center><?php echo $t->TampilNamaBarang($t->TampilHasilCariBarang4($kategori, $provinsi)[$count]) ?></center></b></a>
                                                    <?php
                                                    if ($status != '') {
                                                        ?>
                                                        <!--                                                <div class="row">
                                                                                                            <div class="col-md-5 col-xs-3">
                                                                                                                <h5 class="h5Like"><a href="#">Like  <span class="badge">200</span></a></h5>
                                                                                                            </div>
                                                                                                            <div class="col-md-7 col-xs-4">
                                                                                                                <h5 class="h5Comment"><a href="#">Comment  <span class="badge">150</span></a></h5>
                                                                                                            </div>
                                                                                                        </div>-->
                                                        <br>
                                                        <ul class="list-group">
                                                            <li class="list-group-item"></li>
                                                            <li class="list-group-item"></li>
                                                            <li class="list-group-item"></li>
                                                            <li class="list-group-item"></li>
                                                        </ul>
                                                    <?php }
                                                    ?>
                                                </div>
                                            </center>
                                        </div>
                                        <?php
                                    } else {
                                        $iftrue = 0;
                                    }
                                    $count++;
                                }
                                ?></div><?php
                        }
                    } else {
                        ?>
                        <h2>No Result</h2>
                        <?php
                    }
                } else if ($kategori == '') {
                    if (sizeof($t->TampilHasilCariBarang3($katakunci, $provinsi)) > 0) {
                        for ($index = 0; $index < 20 && $iftrue == 1; $index++) {
                            ?><div class="row"><?php
                            for ($index1 = 0; $index1 < 4 && $iftrue == 1; $index1++) {
                                if ($count < sizeof($t->TampilHasilCariBarang3($katakunci, $provinsi))) {
                                    ?>
                                        <div class="col-md-3 col-xs-12">
                                            <center>
                                                <div class="panel-body utama">
                                                    <a href="deskripsiBarang.php?barang=<?php echo $t->TampilHasilCariBarang3($katakunci, $provinsi)[$count] ?>"><img src="<?php echo $t->TampilUrlGambarBarang($t->TampilHasilCariBarang3($katakunci, $provinsi)[$count]) ?>" class="img-thumbnail"/></a>
                                                    <a href="deskripsiBarang.php?barang=<?php echo $t->TampilHasilCariBarang3($katakunci, $provinsi)[$count] ?>"><b><center><?php echo $t->TampilNamaBarang($t->TampilHasilCariBarang3($katakunci, $provinsi)[$count]) ?></center></b></a>
                                                    <?php
                                                    if ($status != '') {
                                                        ?>
                                                        <!--                                                <div class="row">
                                                                                                            <div class="col-md-5 col-xs-3">
                                                                                                                <h5 class="h5Like"><a href="#">Like  <span class="badge">200</span></a></h5>
                                                                                                            </div>
                                                                                                            <div class="col-md-7 col-xs-4">
                                                                                                                <h5 class="h5Comment"><a href="#">Comment  <span class="badge">150</span></a></h5>
                                                                                                            </div>
                                                                                                        </div>-->
                                                        <br>
                                                        <ul class="list-group">
                                                            <li class="list-group-item"></li>
                                                            <li class="list-group-item"></li>
                                                            <li class="list-group-item"></li>
                                                            <li class="list-group-item"></li>
                                                        </ul>
                                                    <?php }
                                                    ?>
                                                </div>
                                            </center>
                                        </div>
                                        <?php
                                    } else {
                                        $iftrue = 0;
                                    }
                                    $count++;
                                }
                                ?></div><?php
                        }
                    } else {
                        ?>
                        <h2>No Result</h2>
                        <?php
                    }
                } else if ($provinsi == '') {
                    if (sizeof($t->TampilHasilCariBarang2($katakunci, $kategori)) > 0) {
                        for ($index = 0; $index < 20 && $iftrue == 1; $index++) {
                            ?><div class="row"><?php
                            for ($index1 = 0; $index1 < 4 && $iftrue == 1; $index1++) {
                                if ($count < sizeof($t->TampilHasilCariBarang2($katakunci, $kategori))) {
                                    ?>
                                        <div class="col-md-3 col-xs-12">
                                            <center>
                                                <div class="panel-body utama">
                                                    <a href="deskripsiBarang.php?barang=<?php echo $t->TampilHasilCariBarang2($katakunci, $kategori)[$count] ?>"><img src="<?php echo $t->TampilUrlGambarBarang($t->TampilHasilCariBarang2($katakunci, $kategori)[$count]) ?>" class="img-thumbnail"/></a>
                                                    <a href="deskripsiBarang.php?barang=<?php echo $t->TampilHasilCariBarang2($katakunci, $kategori)[$count] ?>"><b><center><?php echo $t->TampilNamaBarang($t->TampilHasilCariBarang2($katakunci, $kategori)[$count]) ?></center></b></a>
                                                    <?php
                                                    if ($status != '') {
                                                        ?>
                                                        <!--                                                <div class="row">
                                                                                                            <div class="col-md-5 col-xs-3">
                                                                                                                <h5 class="h5Like"><a href="#">Like  <span class="badge">200</span></a></h5>
                                                                                                            </div>
                                                                                                            <div class="col-md-7 col-xs-4">
                                                                                                                <h5 class="h5Comment"><a href="#">Comment  <span class="badge">150</span></a></h5>
                                                                                                            </div>
                                                                                                        </div>-->
                                                        <br>
                                                        <ul class="list-group">
                                                            <li class="list-group-item"></li>
                                                            <li class="list-group-item"></li>
                                                            <li class="list-group-item"></li>
                                                            <li class="list-group-item"></li>
                                                        </ul>
                                                    <?php }
                                                    ?>
                                                </div>
                                            </center>
                                        </div>
                                        <?php
                                    } else {
                                        $iftrue = 0;
                                    }
                                    $count++;
                                }
                                ?></div><?php
                        }
                    } else {
                        ?>
                        <h2>No Result</h2>
                        <?php
                    }
                } else {
                    if (sizeof($t->TampilHasilCariBarang1($katakunci, $kategori, $provinsi)) > 0) {
                        for ($index = 0; $index < 20 && $iftrue == 1; $index++) {
                            ?><div class="row"><?php
                            for ($index1 = 0; $index1 < 4 && $iftrue == 1; $index1++) {
                                if ($count < sizeof($t->TampilHasilCariBarang1($katakunci, $kategori, $provinsi))) {
                                    ?>
                                        <div class="col-md-3 col-xs-12">
                                            <center>
                                                <div class="panel-body utama">
                                                    <a href="deskripsiBarang.php?barang=<?php echo $t->TampilHasilCariBarang1($katakunci, $kategori, $provinsi)[$count] ?>"><img src="<?php echo $t->TampilUrlGambarBarang($t->TampilHasilCariBarang1($katakunci, $kategori, $provinsi)[$count]) ?>" class="img-thumbnail"/></a>
                                                    <a href="deskripsiBarang.php?barang=<?php echo $t->TampilHasilCariBarang1($katakunci, $kategori, $provinsi)[$count] ?>"><b><center><?php echo $t->TampilNamaBarang($t->TampilHasilCariBarang1($katakunci, $kategori, $provinsi)[$count]) ?></center></b></a>
                                                    <?php
                                                    if ($status != '') {
                                                        ?>
                                                        <!--                                                <div class="row">
                                                                                                            <div class="col-md-5 col-xs-3">
                                                                                                                <h5 class="h5Like"><a href="#">Like  <span class="badge">200</span></a></h5>
                                                                                                            </div>
                                                                                                            <div class="col-md-7 col-xs-4">
                                                                                                                <h5 class="h5Comment"><a href="#">Comment  <span class="badge">150</span></a></h5>
                                                                                                            </div>
                                                                                                        </div>-->
                                                        <br>
                                                        <ul class="list-group">
                                                            <li class="list-group-item"></li>
                                                            <li class="list-group-item"></li>
                                                            <li class="list-group-item"></li>
                                                            <li class="list-group-item"></li>
                                                        </ul>
                                                    <?php }
                                                    ?>
                                                </div>
                                            </center>
                                        </div>
                                        <?php
                                    } else {
                                        $iftrue = 0;
                                    }
                                    $count++;
                                }
                                ?></div><?php
                        }
                    } else {
                        ?>
                        <h2>No Result</h2>
                        <?php
                    }
                }
                ?>
            </div>
            <div class="panel panel-default panelKat">
                <div class="panel-footer panelKaki">
                    <div class="row">
                        <div class="col-md-12 col-xs-12">
                            <br><br><br>
                            <center><label class="fontKaki"><h4>@ Copyright 2014 semua berbagi - All right reserved</h4></label></center>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <script src="js/jquery.min.js"></script>
        <script src="js/bootstrap.js"></script>
    </div>
</body>
</html>
